import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class FormTest extends StatefulWidget {
  FormTest({Key key}) : super(key: key);

  @override
  _FormTestState createState() => _FormTestState();
}

class _FormTestState extends State<FormTest> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
       resizeToAvoidBottomPadding: false,
        backgroundColor: Colors.white,
        appBar: AppBar(
          brightness: Brightness.dark,
          iconTheme: IconThemeData(color: Colors.white),
          title: Text(
            "表单",
            style: TextStyle(color: Colors.white),
          ),
          backgroundColor: Colors.red,
        ),
        // appBar: MAppBar(
        //   child:Container(
        //     height: 56.0,
        //     color: Colors.white,
        //     alignment: Alignment.center,
        //     child: Text("表单"),
        //   ) ,
        // ),
        body: Padding(
          padding: EdgeInsets.all(20.0),
          child: Column(
            children: <Widget>[
              TextField(
                decoration: InputDecoration(
                  hintText: "请输入内容",
                ),
              ),
              SizedBox(height: 10),
              TextField(
                decoration: InputDecoration(
                  hintText: "请输入内容",
                  hintStyle:TextStyle(color: Colors.black12),
                  border: OutlineInputBorder(),
                ),
              ),
              SizedBox(height: 10),
              TextField(
                maxLines: 4,
                decoration: InputDecoration(
                    hintText: "请输入内容", border: OutlineInputBorder()),
              ),
              SizedBox(height: 10),
              TextField(
                obscureText: true,
                decoration: InputDecoration(
                    hintText: "密码框", border: OutlineInputBorder()),
              ),
              SizedBox(height: 10),
              Container(
                decoration: BoxDecoration(
                  border: Border(bottom: BorderSide(color: Colors.black12))
                ),
                child: TextField(
                  keyboardType: TextInputType.number,
                  decoration: InputDecoration(
                    hintText: "用户名",
                    hintStyle:TextStyle(color: Colors.black12),
                    border: OutlineInputBorder(
                      //borderRadius: BorderRadius.circular(15),
                      borderSide: BorderSide.none,
                    ),
                    //labelText: "用户名",
                    contentPadding: const EdgeInsets.all(10),
                  ),
                ),
              )
            ],
          ),
        ));
  }
}

//自定义appbar
class MAppBar extends StatefulWidget implements PreferredSizeWidget {
  MAppBar({@required this.child}) : assert(child != null);
  final Widget child;
  @override
  Size get preferredSize {
    return new Size.fromHeight(56.0);
  }

  @override
  State createState() {
    return new MAppBarState();
  }
}

class MAppBarState extends State<MAppBar> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return new SafeArea(
      top: true,
      child: widget.child,
    );
  }
}
